/**
 * Created by fj on 2016/11/15.
 */
require('jquery');
if (window.top != window.self){
    window.top.location.href = '/mms';
}
$(function () {
    $("#bt_captcha").click(function () {
        $("#login-cod").attr('src','getCode?t=' + Math.random());
    });
    $(".login-button").click(function (e) {
        e.preventDefault();
        submit();
    });
    $("#loginForm").keydown(function(e){
        if(e.keyCode == 13)
        {
            submit();
            return false;
        }
    });
    $("#username").focus();
    function submit() {
        var username =  $("#username").val();
        var password = $("#password").val();
        var validateCode = $("#validateCode").val();
        if(!username || username.length<1){
            $("#msg").text("请填写用户名");
            $("#msg").show();
            return;
        }
        else if(!password || password.length<1){
            $("#msg").text("请填写密码");
            $("#msg").show();
            return;
        }
        else if($("#validateCode").length && (!validateCode || validateCode.length<1)){
            $("#msg").text("请填写验证码");
            $("#msg").show();
            return;
        }
        $("#loginForm").submit();
    }
})